<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /*当promise的excutor为同步，即直接调用resolve/reject时，先改变状态再指定回调*/
        let P1 = new Promise((resolve, reject) => {
            resolve("success")
        });
        P1.then(value => {
            console.log(value)
        })
        /*当promise的excutor为异步时，先指定回调，再改变状态*/
        let P2  = new Promise((resolve, reject) => {
            setTimeout( () => {
                resolve("success")
            }, 1000)
        });
        P2.then(value => {
            console.log(value)
        })
    </script>
</body>
</html>